import 'dart:convert';

AssignmentDto assignmentDtoFromJson(String str) =>
    AssignmentDto.fromJson(json.decode(str));

String assignmentDtoToJson(AssignmentDto data) => json.encode(data.toJson());

class AssignmentDto {
  AssignmentDto({
    this.allStudentInClass,
    this.workType,
    this.bookIds,
    this.extraPoints,
    this.instruction,
    this.instructionTrueOrFalse,
    this.name,
    this.noOfBookToBeRead,
    this.numBooks,
    this.settings,
    this.createDate,
    this.endDate,
    this.startDate,
    this.studentUserNames,
    this.addBookIds,
  });

  bool? allStudentInClass;
  String? workType;
  List<String>? bookIds;
  int? extraPoints;
  String? instruction;
  bool? instructionTrueOrFalse;
  String? name;
  int? noOfBookToBeRead;
  int? numBooks;
  Settings? settings;
  int? createDate;
  int? endDate;
  int? startDate;
  List<String>? studentUserNames;
  List<String>? addBookIds;

  factory AssignmentDto.fromJson(Map<String, dynamic> json) => AssignmentDto(
        allStudentInClass: json["allStudentInClass"],
        workType: json["workType"],
        bookIds: json["bookIds"] != null
            ? List<String>.from(json["bookIds"].map((x) => x))
            : null,
        extraPoints: json["extraPoints"],
        instruction: json["instruction"],
        instructionTrueOrFalse: json["instructionTrueOrFalse"],
        name: json["name"],
        noOfBookToBeRead: json["noOfBookToBeRead"],
        numBooks: json["numBooks"],
        settings: Settings.fromJson(json["settings"]),
        createDate: json["createDate"],
        endDate: json["endDate"],
        startDate: json["startDate"],
        studentUserNames: json["studentUserNames"] != null
            ? List<String>.from(json["studentUserNames"].map((x) => x))
            : null,
      );

  Map<String, dynamic> toJson() => {
        "allStudentInClass": allStudentInClass,
        "workType": workType,
        "bookIds":
            bookIds != null ? List<dynamic>.from(bookIds!.map((x) => x)) : null,
        "extraPoints": extraPoints,
        "instruction": instruction,
        "instructionTrueOrFalse": instructionTrueOrFalse,
        "name": name,
        "noOfBookToBeRead": noOfBookToBeRead,
        "numBooks": numBooks,
        "settings": settings != null ? settings?.toJson() : null,
        "createDate": createDate,
        "endDate": endDate,
        "startDate": startDate,
        "studentUserNames": studentUserNames != null
            ? List<dynamic>.from(studentUserNames!.map((x) => x))
            : null,
        "addBookIds": addBookIds != null
            ? List<dynamic>.from(addBookIds!.map((x) => x))
            : null,
      };
}

class Settings {
  Settings({
    this.audio,
    this.lang,
    this.language,
    this.pinyin,
    this.quizAudio,
  });

  bool? audio;
  String? lang;
  String? language;
  bool? pinyin;
  bool? quizAudio;

  factory Settings.fromJson(Map<String, dynamic> json) => Settings(
        audio: json["audio"],
        lang: json["lang"],
        language: json["language"],
        pinyin: json["pinyin"],
        quizAudio: json["quizAudio"],
      );

  Map<String, dynamic> toJson() => {
        "audio": audio,
        "lang": lang,
        "language": language,
        "pinyin": pinyin,
        "quizAudio": quizAudio,
      };
}
